package com.twelve.controller;

import com.twelve.utils.JqgridUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: twelve
 * @description:
 * @author: geyuqi
 * @create: 2018-11-22 17:13
 **/

@Controller
@RequestMapping("/static")
public class StaticController {

    @Autowired
    private JqgridUtil jqgridUtil;

    @RequestMapping("/recently")
    public String collumn(HttpServletRequest request){
        return "recently";
    }

    @ResponseBody
    @RequestMapping("/recenty/list")
    public String list(HttpServletRequest request){
        String page = request.getParameter("page"); // 取得当前页数,注意这是jqgrid自身的参数
        String rows = request.getParameter("rows"); // 取得每页显示行数，,注意这是jqgrid自身的参数
        List all = new ArrayList();

        Map map = new HashMap<>();
        map.put("name", "李明");
        map.put("area", "北京");
        map.put("content", "注浆泵活塞采购价格超标，原范围2750~2850 采购价3035");
        map.put("time", "2018/10/12 06:00");
        all.add(map);


        Map map1 = new HashMap<>();
        map1.put("name", "王自建");
        map1.put("area", "长沙");
        map1.put("content", "缓冲托辊采购价格超标，原范围500~520,采购价600");
        map1.put("time", "2018/10/12 06:00");
        all.add(map1);


        Map map2 = new HashMap<>();
        map2.put("name", "最帅琦哥");
        map2.put("area", "哈尔滨");
        map2.put("content", "安全帽采购价格超标，原范围15~25,采购价100");
        map2.put("time", "2018/10/12 06:00");
        all.add(map2);

        return jqgridUtil.getJson(all, "1", all.size() , 3);



//        int toIndex = count * page;
//        if (all.size() < toIndex) {
//            toIndex = all.size();
//        }
//        List<Collumn> list = all.subList(count * (page - 1), toIndex);
//        return jqgridUtil.getJson(list, page + "", all.size() , count);

    }
}
